﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FamilyBook.Core;
using FamilyBook.UI.WPF.Views;
using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.Unity;

namespace FamilyBook.UI.WPF.Modules
{
    public class TransactionsListModule : IModule
    {
        private readonly IRegionManager _regionManager;
        private readonly IUnityContainer _iocContainer;

        public TransactionsListModule(IUnityContainer iocContainer, IRegionManager regionManager)
        {
            _regionManager = regionManager;
            _iocContainer = iocContainer;
        }

        public void Initialize()
        {
            _regionManager.RegisterViewWithRegion("TransactionsListView", GetTransactionsListView);
        }

        private TransactionsListView GetTransactionsListView()
        {
            var dbSession = _iocContainer.Resolve<IDbSession>();
            return _iocContainer.Resolve<TransactionsListView>(new DependencyOverride<IDbSession>(dbSession));
        }

    }
}
